<?php
/* -------------------------------------------------------------------------
 * 
 * Nom du fichier : accueil.php
 *
 * -------------------------------------------------------------------------
 */

// Définition du répertoire root
define('SITE_ROOT', '..');
 
// Définition du fuseau horaire
date_default_timezone_set("Europe/Paris");

// Session Start
session_start();

// Include
include(SITE_ROOT . '/inc/functions_debug.php');
include(SITE_ROOT . '/inc/class_db.php');
include(SITE_ROOT . '/inc/include.php');

// Vérification auth
check_auth();

// Début du html
htmlstart();

// Header
divheader();

//Contenu central
?>
<section>
    <aside id="profilaside">
        <p>Poster une nouvelle video :</p>
        <form method="post">
            <label for="lienvideo">Ton lien :</label>
            <input name="lienvideo" id="lienvideo" placeholder="Lien de ta video"/>
            <label for="msgvideo">Ton message :</label>
            <textarea name="msgvideo" wrap="hard" id="msgvideo" rows="2" cols="30" placeholder="Ton message ici..."></textarea>
            <input type="submit" value="Poster"/>
        </form>
    </aside>
    <section id="sec_flux">
        <?
        //Ouvre la connexion à la base de donnée
        $db = New Database;

        $sql = "SELECT * FROM video ORDER BY date ASC";
        $db->array_query($sql);

        ?>
        <article>
        <?
        while( $row = $db->retourArray() ) {
            $sql2 = "SELECT * FROM users WHERE id = ".$row['user']."";
            $db->select_query($sql2);
            $senduser = $db->retourLigne();
            $msgcont = htmlspecialchars($row['msg'],ENT_QUOTES);
            $msgcont = smyle($msgcont);
            ?>
            <div class="msg">
                <img src="<?=$senduser['img']?>" alt="<?=$senduser['nom']?>" width="50" height="50"/>
                <h4><?=$senduser['nom']?></h4>
                <p class="date_p"><?=$row['date']?></p>
                <p class="bulle"><?=$msgcont?></p>
                <iframe id="videobox" width="560" height="315" src="<?=$row['lien']?>" frameborder="0" allowfullscreen></iframe>
            </div>
            <?
        }
        ?>
        </article>
    </section>
</section>
<?

// Footer
divfooter();

// Fin du html
htmlstop();

// Debug                                                                                                                                                                  
// debug_environnement();

?>
